package edu.ecnu.yt.spring.di.ambiguity;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import edu.ecnu.yt.spring.di.ambiguity.shape.Circle;
import edu.ecnu.yt.spring.di.ambiguity.shape.Rectangle;
import edu.ecnu.yt.spring.di.ambiguity.shape.Shape;
import edu.ecnu.yt.spring.di.ambiguity.shape.Square;
import edu.ecnu.yt.spring.di.ambiguity.shape.Triangle;

@Configuration
public class AmbiguityConfig {
	@Bean
	public Shape circle() {
		return new Circle();
	}
	
	@Bean
	@Qualifier("myCircle")
	public Shape myCircle() {
		return new Circle();
	}
	
	@Bean
	public Shape triangle() {
		return new Triangle();
	}
	
	@Bean
	@Quadrangle // 四边形
	@UnequalSides // 不等边
	@Primary // 指定rectangle为首选的bean
	public Shape rectangle() {
		return new Rectangle();
	}
	
	@Bean
	@Quadrangle // 四边形
	@EqualSides // 等边
	public Shape square() {
		return new Square();
	}
}
